/*
 * 2006-04-18 Li Ximing, Zhang Yanbo - Create.
 */
package com.hd123.rumba.log;

import java.util.List;

import net.sf.hibernate.Hibernate;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.type.Type;

import com.hd123.rumba.exception.BusinessException;

/**
 * 实体日志 | 管理员 | 实现类
 * 
 * @author lxm
 * @author zhangyanbo
 * 
 */
public class EntityLogMgr extends OperateLogMgr implements IEntityLogMgr {

  public EntityLogMgr() {
    super();
    this.registryClass("com.hd123.rumba.log.IEntityLog", "com.hd123.rumba.log.EntityLog");
  }

  public IEntityLog createLog() {
    return new EntityLog();
  }

  public List<IEntityLog> getLogsByEntity(String entityUuid) throws BusinessException,
      HibernateException {
    this.checkParameterNotNull(entityUuid, "entityUuid");

    List<IEntityLog> list = getSession().find(
        "from " + IEntityLog.class.getName() + " el where el.entityUuid = ?", entityUuid,
        Hibernate.STRING);
    return list;
  }

  public List<IEntityLog> getLogsByEntityAndEvent(String entityUuid, String event)
      throws BusinessException, HibernateException {
    this.checkParameterNotNull(entityUuid, "entityUuid");
    this.checkParameterNotNull(event, "event");

    List<IEntityLog> list = getSession().find(
        "from " + IEntityLog.class.getName() + " el where el.entityUuid = ? and el.event = ? ",
        new Object[] {
            entityUuid, event }, new Type[] {
            Hibernate.STRING, Hibernate.STRING });
    return list;
  }

}
